/*************************************************************************
> File Name: 02_test.cpp
> Author: hzy
> Created Time: 2023-08-14 11:33:23
> Description:对象构造和析构的调用顺序
************************************************************************/
#include <iostream>

using namespace std;

class Base1
{
public:
    int val;

public:
    Base1(int myval)
    {
        val = myval;
        cout << "Base1()" << endl;
    }
    ~Base1()
    {
        cout << "~Base1()" << endl;
    }

public:
    void father1()
    {
        cout << "father1():val = " << val << endl;
    }
};

class Base2
{
public:
    int num;

public:
    Base2(int mynum)
    {
        num = mynum;
        cout << "Base2()" << endl;
    }
    ~Base2()
    {
        cout << "~Base2()" << endl;
    }

public:
    void father2()
    {
        cout << "father2():num = " << num << endl;
    }
};
class Son1 : public Base1, public Base2
{
public:
    Son1(int myval, int mynum) : Base1(myval), Base2(mynum)
    {
        cout << "Son1()" << endl;
    }
    ~Son1()
    {
        cout << "~Son1()" << endl;
    }
};

int main()
{
    Son1 son1(1, 9);

    son1.father1();
    son1.father2();

    return 0;
}